package com.fresh.bus.chat.business;

import java.util.Calendar;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class BusTravel extends QuartzJobBean {
	private static final Logger log = LoggerFactory.getLogger(BusTravel.class);

	protected String line1Station[];

	private long startTime;
	
	private long interval = 6*60*1000; //列车间隔时长

	private int index = 0;

	
	  private int timeout;
	  
	  /**
	   * Setter called after the ExampleJob is instantiated
	   * with the value from the JobDetailBean (5)
	   */ 
	  public void setTimeout(int timeout) {
	    this.timeout = timeout;
	  }
	  
	  protected void executeInternal(JobExecutionContext ctx) throws JobExecutionException {
	      // do the actual work
	  }
	  
	// 安排座位
	public void assignSeat() {
		//log.debug("Method assign seat execute...");
	}

	public void arriveSign() {
		startTime = Calendar.getInstance().getTimeInMillis();
		if (index >= line1Station.length) {
			index = 0;
		} else {
			index++;
		}
		//log.debug("Method arrive sign execute...");
	}

	public String getCurrentStation() {
		return line1Station[index];
	}

	public String getNextStation() {
		return line1Station[index + 1];
	}

	public long getRetainTime() {
		long current = System.currentTimeMillis();
		long len = interval - (current - startTime);
		return len;
	}
}
